# -*- coding: utf-8 -*-
'''
Created on Apr 24, 2011

@author: Yang Sun
'''

import urllib, re
from common import decode
class Program:
    '''
    classdocs
    '''            

    def __init__(self, vid, playlink, title, type, catalog, director, 
                 act, year, area, imgurl, state, note, mark, hot, 
                 pv, bitrate, resolution, flag, duration):        
        '''
        Constructor
        '''
        self.vid = vid
        self.playlink = urllib.unquote_plus(playlink)
        self.playlink_decode = decode(self.playlink, 'kioe257ds')
        match = re.search('.+\|\|(.+)', self.playlink_decode)           
        self.file_name = match.group(1)             
        self.title = title
        self.type = type
        self.catalog = catalog
        self.director = director
        self.act = act
        self.year = year
        self.area = area
        self.imgurl = imgurl
        self.state = state
        self.note = note
        self.mark = mark
        self.hot = hot
        self.pv = pv
        self.bitrate = bitrate
        self.resolution = resolution
        self.flag = flag
        self.duration = duration

    def __str__(self):
        template = \
        '''
        vid = %s
        playlink = %s
        title = %s
        type = %s 
        catalog = %s
        director = %s
        act = %s
        year = %s
        area = %s
        imgurl = %s
        state = %s
        note = %s
        mark = %s
        hot = %s
        pv = %s
        bitrate = %s
        resolution = %s
        flag = %s
        duration = %s
        ''' % (self.vid, self.playlink, self.title, self.type, self.catalog, self.director,
               self.act, self.year, self.area, self.imgurl, self.state, self.note, self.mark,
               self.hot, self.pv, self.bitrate, self.resolution, self.flag, self.duration)
        
        return template 
    